<template>
  <div class="h-full">
    <fs-crud ref="crudRef" v-bind="crudBinding" />
  </div>
</template>

<script lang="ts" setup>
import { onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useFs, dict } from '@fast-crud/fast-crud';
import createCrudOptions from './crud';

const router = useRouter();
const route = useRoute();

const apiPrefix = '/advice';
const context: any = {
  router,
  apiPrefix,
  columns: {
    description: {
      title: '描述',
      type: 'text'
    },
    username: {
      title: '描述人',
      type: 'text',
      search: { show: true }
    }
  }
};

const { crudRef, crudBinding, crudExpose } = useFs({
  createCrudOptions,
  context
});

onMounted(() => {
  if (route.query.id) {
    console.log('onMounted...', route.query.id);
  }

  crudExpose.doRefresh();
});
</script>
